package com.example.content.fragment.me.coin

import androidx.recyclerview.widget.LinearLayoutManager
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.content.BuildConfig
import com.example.content.R
import com.example.content.adapter.recycle.BindListener
import com.example.content.adapter.recycle.RecyclerAdapter
import com.example.content.adapter.recycle.entity.ItemEntity
import com.example.content.databinding.RecyclerviewLayoutBinding
import com.example.content.fragment.BaseMvvmFragment
import com.example.content.repository.bean.ChargeInfo
import com.example.content.viewmodule.me.MyPageCommonViewModel

/**
 * Created by zhudongao
 * Desc
 * Date 2020/11/11
 */
class ChargeListFragment : BaseMvvmFragment<RecyclerviewLayoutBinding, MyPageCommonViewModel>()  {

    private lateinit var adapter:RecyclerAdapter<ChargeInfo>

    override fun initView() {
        adapter = RecyclerAdapter(object :BindListener<ChargeInfo>{
            override fun convert(holder: BaseViewHolder, item: ItemEntity<ChargeInfo>) {

            }
        })
        adapter.addItemView(R.layout.item_charge_record_layout)
        // TODO: 2020/11/12 mock数据
        if (BuildConfig.DEBUG) {
            adapter.data.add(ItemEntity(data = ChargeInfo()))
            adapter.data.add(ItemEntity(data = ChargeInfo()))
            adapter.data.add(ItemEntity(data = ChargeInfo()))
            adapter.data.add(ItemEntity(data = ChargeInfo()))
        }
        dataBinding.recyclerView.adapter = adapter
        dataBinding.recyclerView.layoutManager = LinearLayoutManager(context)
    }

    override fun queryData() {
        // TODO: 2020/11/12 请求支付记录
    }

    override fun getLayoutId() = R.layout.recyclerview_layout

    companion object {
        @JvmStatic
        fun newInstance() = ChargeListFragment()
    }

    override fun getViewModuleClass(): Class<MyPageCommonViewModel> {
        return MyPageCommonViewModel::class.java
    }
}